home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / vm / sun4.md / vmSunConst.h < prev   
Encoding:
C/C++ Source or Header  |  1992-12-19  |  19.8 KB  |  529 lines

  1. /*
  2.  * vmSunConst.h --
  3.  *
  4.  *         Virtual memory constants for the Sun4.
  5.  *
  6.  * Copyright (C) 1985 Regents of the University of California
  7.  * All rights reserved.
  8.  *
  9.  *
  10.  * $Header: /cdrom/src/kernel/Cvsroot/kernel/vm/sun4.md/vmSunConst.h,v 9.10 92/10/26 12:02:19 elm Exp $ SPRITE (Berkeley)
  11.  */
  12.  
  13. #ifndef _VMSUNCONST
  14. #define _VMSUNCONST
  15.  
  16. /*
  17.  * Sun3 page table entry masks.  The same for the sun4.
  18.  *
  19.  *    VMMACH_RESIDENT_BIT    The page is physical resident.        31
  20.  *    VMMACH_PROTECTION_FIELD    Access to the protection bits.        30:29
  21.  *    VMMACH_KR_PROT        Kernel read only, user no access.
  22.  *    VMMACH_KRW_PROT        Kernel read/write, user no access.
  23.  *    VMMACH_UR_PROT        Kernel read only, user read only
  24.  *    VMMACH_URW_PROT        Kernel read/write, user read/write.
  25.  *    VMMACH_DONT_CACHE_BIT    Don't cache bit.            28
  26.  *    VMMACH_TYPE_FIELD        The memory type field.            27:26
  27.  *    VMMACH_REFERENCED_BIT    Referenced bit.                25
  28.  *    VMMACH_MODIFIED_BIT    Modified bit.                24
  29.  *    VMMACH_PAGE_FRAME_FIELD    The hardware page frame.        18:0
  30.  */
  31. #define    VMMACH_RESIDENT_BIT    0x80000000
  32. #define    VMMACH_PROTECTION_FIELD    0x60000000
  33. #define    VMMACH_UR_PROT        0x00000000
  34. #define    VMMACH_KR_PROT        0x20000000
  35. #define VMMACH_URW_PROT        0x40000000
  36. #define    VMMACH_KRW_PROT        0x60000000
  37. #define    VMMACH_DONT_CACHE_BIT    0x10000000
  38. #define    VMMACH_TYPE_FIELD    0x0c000000
  39. #define VMMACH_REFERENCED_BIT    0x02000000
  40. #define    VMMACH_MODIFIED_BIT    0x01000000
  41. #ifdef sun4c
  42. #define VMMACH_PAGE_FRAME_FIELD    0x0000ffff
  43. #else
  44. #define VMMACH_PAGE_FRAME_FIELD    0x0007ffff
  45. #endif
  46. /*
  47.  * Shift to allow the type field to get set.
  48.  */
  49. #define    VmMachGetPageType(pte) (((pte) >> 26) & 3)
  50. #define    VmMachSetPageType(pte, type) (pte |= (type << 26))
  51.  
  52. /* Value of VMMACH_TYPE_FIELD */
  53. #define    VMMACH_TYPE_MEM        0        /* Main memory. */
  54. #define    VMMACH_TYPE_DEV        1        /* Serial ports, net regs... */
  55. #define VMMACH_TYPE_VME16DATA    2        /* 16-bit vme data. */
  56. #define    VMMACH_TYPE_VME32DATA    3        /* 32-bit vme data. */
  57.  
  58. /*
  59.  * Shift pte right by this much to isolate page protection and residence bits.
  60.  */
  61. #define    VMMACH_PAGE_PROT_SHIFT    29
  62. /*
  63.  * Compare shifted pte (above) with this to see if user residence and protection
  64.  * are okay for the user to write to this address.
  65.  */
  66. #define    VMMACH_PTE_OKAY_VALUE    6
  67.  
  68. /*
  69.  * In the sun4 200 series machines, the 2 high bits may be 00 or 11.  However,
  70.  * 00 and 11 actually go to the same entry in the segment table.  So for
  71.  * address comparisons, one may have to strip the high two bits.  The hole in
  72.  * the sun4c space is the same.
  73.  *    VMMACH_BOTTOM_OF_HOLE    first unusable addr in hole
  74.  *    VMMACH_TOP_OF_HOLE    last unusable addr in hole
  75.  *    VMMACH_ADDR_MASK    mask off usable bits of address
  76.  */
  77. #define    VMMACH_BOTTOM_OF_HOLE    0x20000000
  78. #define    VMMACH_TOP_OF_HOLE    (0xe0000000 - 1)
  79. #define    VMMACH_ADDR_MASK    0x3FFFFFFF
  80.  
  81. /*
  82.  * Check to see if a virtual address falls inside the hole in the middle
  83.  * of the sun4 address space.
  84.  */
  85. #if 1
  86. #define    VMMACH_ADDR_CHECK(virtAddr)    \
  87.     (((unsigned int)(virtAddr) + 0x20000000) < 0x40000000)
  88. #else
  89. #define    VMMACH_ADDR_CHECK(virtAddr)    \
  90.     (    ((unsigned int) (virtAddr)) >=    \
  91.             ((unsigned int) VMMACH_BOTTOM_OF_HOLE) &&    \
  92.     ((unsigned int) (virtAddr)) <=    \
  93.             ((unsigned int) VMMACH_TOP_OF_HOLE) ? FALSE : TRUE)
  94. #endif
  95.  
  96. /*
  97.  * Check, in assembly, whether a virtual address falls inside the hole in
  98.  * the middle of the sun4 address space.
  99.  */
  100. #define    VMMACH_ADDR_OK_ASM(virtAddr, CheckMore, DoneCheck, answerReg, useReg) \
  101.     clr    answerReg;                \
  102.     set    VMMACH_BOTTOM_OF_HOLE, useReg;        \
  103.     cmp     useReg, virtAddr;            \
  104.     bleu    CheckMore;                \
  105.     nop;                        \
  106.     ba    DoneCheck;                \
  107.     nop;                        \
  108. CheckMore:                        \
  109.     set    VMMACH_TOP_OF_HOLE, useReg;        \
  110.     cmp    virtAddr, useReg;            \
  111.     bgu    DoneCheck;                \
  112.     nop;                        \
  113.     set    0x1, answerReg;                \
  114. DoneCheck:
  115.  
  116.  
  117. /*
  118.  * Sun memory management unit constants:
  119.  *
  120.  * VMMACH_KERN_CONTEXT        The Kernel's context.
  121.  * VMMACH_NUM_CONTEXTS        The number of contexts. Impl. dependent.
  122.  * VMMACH_NUM_SEGS_PER_CONTEXT    The number of hardware segments per context.
  123.  * VMMACH_NUM_PAGES_PER_SEG_INT    The number of pages per hardware segment.
  124.  * VMMACH_NUM_PAGE_MAP_ENTRIES    The number of hardware page map entries.
  125.  * VMMACH_NUM_PMEGS        The number of page clusters that there are 
  126.  *                in the system.
  127.  * VMMACH_DEV_START_ADDR        The first virtual address that is used for
  128.  *                              mapping devices.
  129.  * VMMACH_DEV_END_ADDR        The last virtual address that could be used for 
  130.  *                mapping devices.
  131.  * VMMACH_DMA_START_ADDR    The first virtual address that is used for 
  132.  *                DMA buffers by devices.
  133.  * VMMACH_DMA_SIZE        The amount of space devoted to DMA buffers
  134.  *
  135.  * VMMACH_32BIT_DMA_START_ADDR    The first address of the 32-bit "user" DVMA
  136.  *                area in context 0.
  137.  * VMMACH_32BIT_DMA_SIZE    The size of the 32-bit "user" DVMA area.  This
  138.  *                should be a multiple of the cache size, for
  139.  *                alignment purposes, and it should be a multile
  140.  *                of the segment size, so as not to waste aPpMEG.
  141.  * VMMACH_VME_ADDR_BIT        The bit that indicates an address is a VME
  142.  *                bus address.
  143.  * VMMACH_NET_MAP_START        The beginning of space for mapping the Intel
  144.  *                and AMD drivers.
  145.  * VMMACH_NET_MEM_START        The beginning of space for memory for the Intel
  146.  *                and AMD drivers.
  147.  * VMMACH_FIRST_SPECIAL_SEG    The first hardware segment that is used for 
  148.  *                mapping devices.
  149.  * VMMACH_INV_PMEG           The page cluster number that is used to 
  150.  *                represent an invalid Pmeg.
  151.  * VMMACH_INV_SEG           The hardware segment number that is used to
  152.  *                represent an invalid hardware segment.
  153.  * VMMACH_INV_CONTEXT       The context number that is used to represent
  154.  *                an invalid context.
  155.  */
  156.  
  157. #define VMMACH_KERN_CONTEXT        0
  158. #ifdef sun4c
  159. #define VMMACH_NUM_CONTEXTS_60        8
  160. #define VMMACH_NUM_CONTEXTS_110        8
  161. #define VMMACH_NUM_CONTEXTS_260        16
  162. #define VMMACH_NUM_CONTEXTS_330        16
  163. #define VMMACH_NUM_CONTEXTS_470        64
  164. #ifdef _ASM                /* force error */
  165. #define VMMACH_NUM_CONTEXTS        %%
  166. #else
  167. #define VMMACH_NUM_CONTEXTS        vmNumContexts
  168. #endif
  169. #else
  170. #define VMMACH_NUM_CONTEXTS        16
  171. #endif
  172.  
  173. /*
  174.  *    VMMACH_NUM_SEGS_PER_CONTEXT    Number of segments per context:
  175.  * There is a hole in the middle of the address space, so really there's only
  176.  * 2**12 segs per context, but having discontinuous maps is a pain, so we
  177.  * pretend it's all mappable, which means there's 2**14 segs per context, on
  178.  * the sun4.  This is calculated from 256K bytes per segment == 0x40000 bytes
  179.  * per segment == 2**18 bytes per segment into 2**32 bytes per context gives
  180.  * (32-18) == 14 segments per context.  The sparc station has the same number
  181.  * of segments per context since segments are the same size.
  182.  *    VMMACH_NUM_PAGES_PER_SEG_INT    Number of pages per segment
  183.  *                    (Implementation dependent)
  184.  *    VMMACH_NUM_PAGE_MAP_ENTRIES    Number of total page map entries
  185.  *    VMMACH_NUM_PMEGS        Number of pmegs
  186.  *    VMMACH_NUM_NET_SEGS        The number of segments used for mapping
  187.  *                    net scatter gather arrays aligned to
  188.  *                    avoid cache flushing.  This number is
  189.  *                    picked by rule of thumb.  Usually there
  190.  *                    are no more than 5 elements in a
  191.  *                    scatter gather array, so 5 segments
  192.  *                    avoids cache flushing.  The 6th segment
  193.  *                    is for mapping any elements beyond this
  194.  *                    consecutively (cache flushing used).
  195.  *    
  196.  */
  197. #define VMMACH_NUM_SEGS_PER_CONTEXT    0x4000    /* 2**14 */
  198. #define VMMACH_NUM_PAGES_PER_SEG_INT    (VMMACH_SEG_SIZE / VMMACH_PAGE_SIZE_INT)
  199. #define    VMMACH_NUM_PMEGS_60        128
  200. #define    VMMACH_NUM_PMEGS_110        256
  201. #define    VMMACH_NUM_PMEGS_260        512
  202. #define    VMMACH_NUM_PMEGS_330        256
  203. #define    VMMACH_NUM_PMEGS_470        1024
  204. #ifdef _ASM                /* force error */
  205. #define VMMACH_NUM_PMEGS        %%
  206. #else /* _ASM */
  207. #define VMMACH_NUM_PMEGS        vmNumPmegs
  208. #endif /* _ASM */
  209. #define VMMACH_NUM_PAGE_MAP_ENTRIES    (VMMACH_NUM_PMEGS * VMMACH_NUM_PAGES_PER_SEG_INT)
  210.  
  211. /* The values of MONSTART and MONEND */
  212. #define VMMACH_DEV_START_ADDR           0xFFD00000
  213. #define    VMMACH_DEV_END_ADDR        0xFFEFFFFF
  214. #define    VMMACH_DMA_START_ADDR        0xFFF00000
  215. #define    VMMACH_DMA_SIZE            0xC0000
  216. #define VMMACH_32BIT_DMA_START_ADDR    0x40000
  217. #define    VMMACH_32BIT_DMA_SIZE        0x800000
  218. #ifdef NOTDEF
  219. /* For raid only */
  220. #define    VMMACH_32BIT_DMA_SIZE        (VMMACH_NUM_PMEGS / 2 * VMMACH_SEG_SIZE)
  221. #endif
  222.  
  223. #define    VMMACH_VME_ADDR_BIT        0x80000000
  224.  
  225. #define    VMMACH_NUM_NET_SEGS        6
  226. #define    VMMACH_NET_MAP_SIZE        (VMMACH_NUM_NET_SEGS * VMMACH_SEG_SIZE)
  227. #define VMMACH_NET_MAP_START        (VMMACH_DEV_START_ADDR - \
  228.                         VMMACH_NET_MAP_SIZE)
  229. #define VMMACH_NET_MEM_START        (VMMACH_DMA_START_ADDR +    \
  230.                         VMMACH_DMA_SIZE)
  231. #define    VMMACH_NET_MEM_SIZE        (0x20000-VMMACH_PAGE_SIZE)
  232. #define    VMMACH_FIRST_SPECIAL_SEG    (((unsigned int) VMMACH_DEV_START_ADDR) >> VMMACH_SEG_SHIFT)
  233.                         /* why is this one - 1??? */
  234. #define    VMMACH_INV_PMEG            (VMMACH_NUM_PMEGS - 1)
  235. #define    VMMACH_INV_SEG            VMMACH_NUM_SEGS_PER_CONTEXT
  236. #define    VMMACH_INV_CONTEXT        VMMACH_NUM_CONTEXTS
  237.  
  238. /*
  239.  * Function code constants for access to the different address spaces as
  240.  * defined by the Sun 4 hardware.  These constants determine which
  241.  * address space is accessed when using a load alternate or store alternate
  242.  * or swap alternate instruction.
  243.  *
  244.  * VMMACH_USER_DATA_SPACE        User data space.
  245.  * VMMACH_USER_PROGRAM_SPACE        User program space
  246.  * VMMACH_KERN_DATA_SPACE        Kernel data space.
  247.  * VMMACH_KERN_PROGRAM_SPACE        Kernel program space.
  248.  * VMMACH_FLUSH_SEG_SPACE        Flush segment (in control space).
  249.  * VMMACH_FLUSH_PAGE_SPACE        Flush page (in control space).
  250.  * VMMACH_FLUSH_CONTEXT_SPACE        Flush context (in control space).
  251.  * VMMACH_CACHE_DATA_SPACE        Cache data instruction (in cntrl space).
  252.  * VMMACH_CONTROL_SPACE            Other parts of control space, including
  253.  *                        the context register, etc.
  254.  * VMMACH_SEG_MAP_SPACE            Segment map (in control space).
  255.  * VMMACH_PAGE_MAP_SPACE        Page map (in control space).
  256.  * VMMACH_HWFLUSH_SEG_SPACE         HW assisted flush cache segment.
  257.  * VMMACH_HWFLUSH_PAGE_SPACE         HW assisted flush cache page.
  258.  * VMMACH_HWFLUSH_CONTEXT_SPACE         HW assisted flush cache context.
  259.  * VMMACH_HWFLUSH_CACHE_SPACE        HW assisted flush cache.
  260.  */
  261.  
  262. #define    VMMACH_CONTROL_SPACE        0x2    /* also called system space */
  263. #define    VMMACH_SEG_MAP_SPACE        0x3
  264. #define    VMMACH_PAGE_MAP_SPACE        0x4
  265. #define    VMMACH_HWFLUSH_SEG_SPACE    0x5
  266. #define    VMMACH_HWFLUSH_PAGE_SPACE    0x6
  267. #define    VMMACH_HWFLUSH_CONTEXT_SPACE    0x7
  268. #define    VMMACH_USER_PROGRAM_SPACE    0x8
  269. #define    VMMACH_KERN_PROGRAM_SPACE    0x9
  270. #define    VMMACH_USER_DATA_SPACE        0xA
  271. #define    VMMACH_KERN_DATA_SPACE        0xB
  272. #define    VMMACH_FLUSH_SEG_SPACE        0xC
  273. #define    VMMACH_FLUSH_PAGE_SPACE        0xD
  274. #define    VMMACH_FLUSH_CONTEXT_SPACE    0xE
  275. #ifdef sun4c
  276. #define    VMMACH_HWFLUSH_CACHE_SPACE    0xF
  277. #else /* sun4c */
  278. #define    VMMACH_CACHE_DATA_SPACE        0xF
  279. #endif /* sun4c */
  280.  
  281. /*
  282.  * Masks for access to different parts of control and device space.
  283.  *
  284.  * VMMACH_CONTEXT_OFF         Offset to context register in control space.
  285.  * VMMACH_DIAGNOSTIC_REG    The address of the diagnostic register.
  286.  * VMMACH_USER_DVMA_ENABLE_REG  Bits to enable user DVMA for different VME 
  287.  *                context.
  288.  * VMMACH_USER_DVMA_MAP        Map of VME context to sun user contexts.
  289.  * VMMACH_BUS_ERROR_REG        The address of the bus error register.
  290.  * VMMACH_ADDR_ERROR_REG    Addr of register storing addr of mem error.
  291.  * VMMACH_ADDR_CONTROL_REG    Addr of control register for memory errors.
  292.  * VMMACH_SYSTEM_ENABLE_REG    The address of the system enable register.
  293.  * VMMACH_ETHER_ADDR        Address of ethernet address in the id prom.
  294.  *                On the sun4c, this is in NVRAM in device space
  295.  *                instead.
  296.  * VMMACH_MACH_TYPE_ADDR    Address of machine type in the id prom.
  297.  *                On sun4c, this is in NVRAM.
  298.  * VMMACH_IDPROM_INC        Amount to increment an address when stepping
  299.  *                through the id prom.
  300.  * VMMACH_CACHE_TAGS_ADDR    Address of cache tags in control space.
  301.  * VMMACH_SYNC_ERROR_REG    Address of sync error reg on sun4c.
  302.  * VMMACH_SYNC_ERROR_ADDR_REG    Address of sync error addr reg on sun4c.
  303.  * VMMACH_ASYNC_ERROR_REG    Address of async error reg on sun4c.
  304.  * VMMACH_ASYNC_ERROR_ADDR_REG    Address of async error addr reg on sun4c.
  305.  */
  306.  
  307. #define    VMMACH_CONTEXT_OFF        0x30000000    /* control space */
  308. #define VMMACH_SYSTEM_ENABLE_REG    0x40000000    /* control space */
  309. #define    VMMACH_CACHE_TAGS_ADDR        0x80000000    /* control space */
  310. #define    VMMACH_SERIAL_PORT_ADDR        0xF0000000    /* control space */
  311.  
  312. #ifdef sun4c
  313. /* 4 bus error registers */
  314. #define    VMMACH_CACHE_DATA_ADDR        0x90000000    /* control space */
  315. #define VMMACH_SYNC_ERROR_REG        0x60000000    /* control space */
  316. #define VMMACH_SYNC_ERROR_ADDR_REG    0x60000004    /* control space */
  317. #define VMMACH_ASYNC_ERROR_REG        0x60000008    /* control space */
  318. #define VMMACH_ASYNC_ERROR_ADDR_REG    0x6000000C    /* control space */
  319. #else /* sun4c */
  320. #define VMMACH_IDPROM_INC        0x01
  321. #define VMMACH_MACH_TYPE_ADDR        0x01
  322. #define VMMACH_ETHER_ADDR        0x02
  323. #define    VMMACH_USER_DVMA_ENABLE_REG    0x50000000      /* control space */
  324. #define VMMACH_BUS_ERROR_REG        0x60000000    /* control space */
  325. #define VMMACH_ADDR_ERROR_REG        0xffd08004    /* device space */
  326. #define VMMACH_ADDR_CONTROL_REG        0xffd08000    /* device space */
  327. #define VMMACH_DIAGNOSTIC_REG        0x70000000    /* control space */
  328. #define    VMMACH_USER_DVMA_MAP        0xD0000000    /* control space */
  329. /*
  330.  * Bit in address error control register to enable reporting of asynchronous
  331.  * memory errors.
  332.  */
  333. #define    VMMACH_ENABLE_MEM_ERROR_BIT    0x40
  334. #endif /* sun4c */
  335.  
  336. /*
  337.  * Other cache constants:
  338.  */
  339. /*
  340.  * Mask to set enable cache bit in the system enable register.
  341.  * Or it with register to enable the cache.
  342.  *    VMMACH_ENABLE_CACHE_BIT        Bit in system enable register
  343.  *                    to turn on the cache.
  344.  *    VMMACH_NUM_CACHE_TAGS        Number of tags in the cache
  345.  *    VMMACH_CACHE_TAG_INCR        Byte size for incrementing thru tags
  346.  *    VMMACH_CACHE_LINE_SIZE        Line size in bytes
  347.  *    VMMACH_CACHE_SHIFT        Number to shift by to = line size
  348.  *    VMMACH_NUM_CACHE_LINES        Number of lines in cache
  349.  *    VMMACH_CACHE_SIZE        Total size of cache in bytes of data
  350.  */
  351. #ifdef sun4c
  352. #define    VMMACH_NUM_CACHE_LINES        0x1000    /* 4K * 16 = 64K cache size */
  353. #else /* sun4c */
  354. #define    VMMACH_NUM_CACHE_LINES_110    0
  355. #define    VMMACH_NUM_CACHE_LINES_260    0x2000
  356. #define    VMMACH_NUM_CACHE_LINES_330    0x2000
  357. #define    VMMACH_NUM_CACHE_LINES_470    0x1000
  358. #define    VMMACH_NUM_CACHE_LINES        0x2000    /* 8K * 16 = 128K cache size */
  359. #endif /* sun4c */
  360. #define    VMMACH_ENABLE_CACHE_BIT        0x10
  361. #define    VMMACH_CACHE_TAG_INCR        0x10
  362. #ifdef sun4c
  363. #define    VMMACH_CACHE_LINE_SIZE_60    0x10
  364. #define    VMMACH_CACHE_LINE_SIZE_110    0
  365. #define    VMMACH_CACHE_LINE_SIZE_260    0x10
  366. #define    VMMACH_CACHE_LINE_SIZE_330    0x10
  367. #define    VMMACH_CACHE_LINE_SIZE_470    0x20
  368. #ifdef _ASM                /* force error */
  369. #define VMMACH_CACHE_LINE_SIZE        %%
  370. #else /* _ASM */
  371. #define VMMACH_CACHE_LINE_SIZE        vmCacheLineSize
  372. #endif /* _ASM */
  373. #else /* sun4c */
  374. #define    VMMACH_CACHE_LINE_SIZE        0x10
  375. #define    VMMACH_CACHE_SHIFT        0x4
  376. #endif /* sun4c */
  377. #define    VMMACH_NUM_CACHE_TAGS        VMMACH_NUM_CACHE_LINES
  378. #define VMMACH_CACHE_SIZE  (VMMACH_CACHE_LINE_SIZE * VMMACH_NUM_CACHE_LINES)
  379.  
  380. /*
  381.  * Other bits in the system enable register.
  382.  */
  383. #define    VMMACH_ENABLE_DVMA_BIT        0x20
  384.  
  385. /*
  386.  * The highest virtual address useable by the kernel for both machine type
  387.  * 1 and machine type 2 and 3 and 4...  This seems to be the largest
  388.  * virtual address plus 1...
  389.  */
  390. #define    VMMACH_MACH_TYPE1_MEM_END    0xF40000
  391. #define    VMMACH_MACH_TYPE2_MEM_END    0x1000000
  392. #define    VMMACH_MACH_TYPE3_MEM_END    0x10000000
  393. #define    VMMACH_MACH_TYPE4_MEM_END    0x100000000
  394.  
  395. /*
  396.  * Masks to extract good bits from the virtual addresses when accessing
  397.  * the page and segment maps.
  398.  */
  399. #ifdef sun4c
  400. #define    VMMACH_PAGE_MAP_MASK    0xFFFFF000
  401. #else
  402. #define    VMMACH_PAGE_MAP_MASK    0xFFFFe000
  403. #endif
  404. #define    VMMACH_SEG_MAP_MASK    0xFFFc0000
  405.  
  406. /*
  407.  * Mask to get only the low order four bits of a context register.
  408.  */
  409. #define    VMMACH_CONTEXT_MASK        0xF
  410.  
  411. /*
  412.  * Hardware dependent constants for pages and segments:
  413.  *
  414.  * VMMACH_CLUSTER_SIZE      The number of hardware pages per virtual page.
  415.  * VMMACH_CLUSTER_SHIFT     The log base 2 of VMMACH_CLUSTER_SIZE.
  416.  * VMMACH_PAGE_SIZE        The size of each virtual page.
  417.  * VMMACH_PAGE_SIZE_INT        The size of each hardware page.
  418.  * VMMACH_PAGE_SHIFT        The log base 2 of VMMACH_PAGE_SIZE.
  419.  * VMMACH_PAGE_SHIFT_INT    The log base 2 of VMMACH_PAGE_SIZE_INT
  420.  * VMMACH_OFFSET_MASK        Mask to get to the offset of a virtual address.
  421.  * VMMACH_OFFSET_MASK_INT    Mask to get to the offset of a virtual address.
  422.  * VMMACH_PAGE_MASK        Mask to get to the Hardware page number within a
  423.  *                hardware segment.
  424.  * VMMACH_SEG_SIZE        The size of each hardware segment.
  425.  * VMMACH_SEG_SHIFT        The log base 2 of VMMACH_SEG_SIZE.
  426.  * VMMACH_NUM_PAGES_PER_SEG    The number of virtual pages per segment.
  427.  */
  428.  
  429. #ifdef sun4c
  430. #if 0
  431. #define VMMACH_CLUSTER_SHIFT    1        /* 1:2 virt page to phys page */
  432. #define VMMACH_PAGE_SHIFT_INT    12        /* 4k */
  433. #else
  434. #define VMMACH_CLUSTER_SHIFT    0        /* 1:1 virt page to phys page */
  435. #define VMMACH_PAGE_SHIFT_INT    12        /* 4k */
  436. #endif
  437. #else /* sun4c */
  438. #define VMMACH_CLUSTER_SHIFT    0        /* 1:1 virt page to phys page */
  439. #define VMMACH_PAGE_SHIFT_INT    13        /* 8k */
  440. #endif /* sun4c */
  441.  
  442. #define    VMMACH_CLUSTER_SIZE    (1 << VMMACH_CLUSTER_SHIFT)
  443. #define    VMMACH_PAGE_SIZE_INT    (1 << VMMACH_PAGE_SHIFT_INT)
  444. #define VMMACH_PAGE_SIZE        (VMMACH_CLUSTER_SIZE * VMMACH_PAGE_SIZE_INT)
  445. #define VMMACH_OFFSET_MASK    (VMMACH_PAGE_SIZE - 1)
  446. #define VMMACH_OFFSET_MASK_INT    (VMMACH_PAGE_SIZE_INT - 1)
  447. #define VMMACH_PAGE_SHIFT    (VMMACH_CLUSTER_SHIFT + VMMACH_PAGE_SHIFT_INT)
  448. #define VMMACH_SEG_SHIFT    18        /* twice as large as sun3? */
  449. #define    VMMACH_SEG_SIZE        (1 << VMMACH_SEG_SHIFT)    /* 0x40000 */
  450. #define VMMACH_PAGE_MASK    (VMMACH_SEG_SIZE - VMMACH_PAGE_SIZE_INT)
  451. #define    VMMACH_NUM_PAGES_PER_SEG (VMMACH_NUM_PAGES_PER_SEG_INT / VMMACH_CLUSTER_SIZE)
  452.  
  453. /*
  454.  * The size that page tables are to be allocated in.  This grows software
  455.  * segments in 256K chunks.  The page tables must grow in chunks that are 
  456.  * multiples of the hardware segment size.  This is because the heap and 
  457.  * stack segments grow towards each other in VMMACH_PAGE_TABLE_INCREMENT 
  458.  * sized chunks.  Thus if the increment wasn't a multiple of the hardware 
  459.  * segment size then the heap and stack segments could overlap on a 
  460.  * hardware segment.
  461.  */
  462. #define    VMMACH_PAGE_TABLE_INCREMENT    (((256 * 1024 - 1) / VMMACH_SEG_SIZE + 1) * VMMACH_NUM_PAGES_PER_SEG)
  463.  
  464. /*
  465.  * The maximum number of kernel stacks.  There is a limit because these
  466.  * use part of the kernel's virtual address space.
  467.  */
  468. #define VMMACH_MAX_KERN_STACKS    128
  469.  
  470. /*
  471.  * The following sets of constants define the kernel's virtual address space. 
  472.  * Some of the constants are defined in machineConst.h.  The address space 
  473.  * looks like the following:
  474.  *
  475.  *    |-------------------------------|    MACH_KERN_START
  476.  *    | Trap vectors.            |
  477.  *    |-------------------------------|    MACH_STACK_BOTTOM
  478.  *    | Invalid page.            |
  479.  *    |-------------------------------|    MACH_STACK_BOTTOM + VMMACH_PAGE_SIZE
  480.  *         |                |
  481.  *         | Stack for the initial kernel     |
  482.  *         | process.            |
  483.  *         |                |
  484.  *    ---------------------------------    MACH_CODE_START
  485.  *         |                |
  486.  *         | Kernel code and data        |
  487.  *         |                 |
  488.  *    ---------------------------------    VMMACH_PMEG_SEG
  489.  *    |                 |
  490.  *    | Stacks, mapped pages, etc.    |
  491.  *    |                 |
  492.  *      ---------------------------------    VMMACH_DEV_START_ADDR
  493.  *    |                |
  494.  *    | Mapped in devices        |
  495.  *    |                |    VMMACH_DEV_END_ADDR
  496.  *    |-------------------------------|    VMMACH_DMA_START_ADDR
  497.  *    |                |
  498.  *    | Space for mapping in DMA bufs |
  499.  *    |                |
  500.  *    |-------------------------------|
  501.  */
  502.  
  503. /*
  504.  * Definitions for supporting the XBUS memory.
  505.  */
  506. #define VmMachIsXbusMem(addr) (((unsigned)(addr) & 0xf0000000) == 0xd0000000)
  507.  
  508. /*
  509.  * There is a special area of a users VAS to allow copies between two user
  510.  * address spaces.  This area sits between the beginning of the kernel and
  511.  * the top of the user stack.  It is one hardware segment wide.
  512.  */
  513. #define    VMMACH_MAP_SEG_ADDR        (MACH_KERN_START - VMMACH_SEG_SIZE)
  514.  
  515. /*
  516.  * Definitions for shared memory.
  517.  * VMMACH_USER_SHARED_PAGES is the number of pages allocated for shared
  518.  *    memory.
  519.  * VMMACH_SHARED_BLOCK_SIZE is the block size in which shared memory is
  520.  *    allocated.  This is a multiple of 128K to avoid cache aliasing.
  521.  * VMMACH_SHARED_START ADDR is the address at which shared memory starts.
  522.  */
  523. #define VMMACH_USER_SHARED_PAGES    8192
  524. #define VMMACH_SHARED_BLOCK_SIZE    VMMACH_SEG_SIZE
  525. #define VMMACH_SHARED_START_ADDR    (VMMACH_BOTTOM_OF_HOLE - VMMACH_USER_SHARED_PAGES*VMMACH_PAGE_SIZE)
  526. #define    VMMACH_SHARED_NUM_BLOCKS    (VMMACH_USER_SHARED_PAGES*VMMACH_PAGE_SIZE/VMMACH_SHARED_BLOCK_SIZE)
  527.  
  528. #endif /* _VMSUNCONST */
  529.